package cn.zf233.jwtshiro.util;

import org.springframework.data.redis.core.SetOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Created by zf233 on 2020/11/27
 * Redis 工具类
 * 文件缓存 & KV操作等
 */
@Component
public class RedisUtil {

    @Resource
    private StringRedisTemplate stringRedisTemplate;

    // String K/V operation
    public void setAdd(String setKey, String value) {
        SetOperations<String, String> ops = stringRedisTemplate.opsForSet();
        ops.add(setKey, value);
    }

    public Boolean isMember(String key, String value) {
        SetOperations<String, String> ops = stringRedisTemplate.opsForSet();
        return ops.isMember(key, value);
    }

    public void sAdd(String key, String value) {
        SetOperations<String, String> ops = stringRedisTemplate.opsForSet();
        ops.add(key, value);
    }
}